package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wechat.domain.Project;
import com.ruoyi.wechat.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 营地其他项目表Controller
 *
 * @author ruoyi

 */
@RestController
@RequestMapping("/wechatt/project")
public class WxProjectController extends BaseController {
    @Autowired
    private IProjectService projectService;

    /**
     * 查询营地其他项目表列表
     */

    @GetMapping("/list")
    public TableDataInfo list(Project project)
    {
        startPage();
        List<Project> list = projectService.selectProjectList(project);
        return getDataTable(list);
    }


    /**
     * 获取营地其他项目表详细信息
     */

    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return success(projectService.selectProjectByProjectId(projectId));
    }
    @GetMapping(value = "/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId)
    {
        return success(projectService.selectProjectBycampId(campId));
    }

    /**
     * 新增营地其他项目表
     */

    @Log(title = "营地其他项目表", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody Project project)
    {
        return success(projectService.insertProject(project));
    }

    /**
     * 修改营地其他项目表
     */

    @Log(title = "营地其他项目表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Project project)
    {
        return toAjax(projectService.updateProject(project));
    }

    /**
     * 删除营地其他项目表
     */

    @Log(title = "营地其他项目表", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{projectId}")
    public AjaxResult remove(@PathVariable String projectId)
    {
        return toAjax(projectService.deleteProjectByProjectId(projectId));
    }
}
